﻿
using System.Net;

using GCC.Container.Abstracts;

namespace GCC.Container.Comm.UDP.Default
{
    /// <summary>
    /// 服务
    /// </summary>
    public class Server : AbsCommUDPServer<string>
    {
        public Server(IPEndPoint iPEndPoint, AbsGCCLogger logger, string name) : base(iPEndPoint, logger, name)
        {
        }

        protected override AbsCommUDPClient<string> GetServer(string name, IPEndPoint localInfo)
        {
            return new Client(localInfo, _logger, name);
        }

        protected override AbsCommUDPClient<string> GetServerClient(string name, IPEndPoint target)
        {
            return new Client(null, _logger, name, target);
        }



        public override AbsCommUDPClient<string> GetClient(string name, IPEndPoint? localEndPoint = null)
        {
            var client = new Client(localEndPoint, _logger, name, _ipEndPoint);
            if (localEndPoint is not null)
            {
                client.StartReceive();
            }
            return client;
        }


    }
}
